package b3.widget.home.town
{
	import b3.net.*;
	import b3.scene.home.*;
	import b3.widget.basic.*;
	import b3.util.*;
	
	import flash.events.*;
	
	import com.greensock.*;
	
	public class DustCan extends BasicWidget
	{
		private var iconImg:ImgSwitchIcon;
		private var hideFlag:Boolean;
		
		public function DustCan()
		{
			var DustIcon0:Class = ResourceHelper.getInstance().getClassByName("DustIcon0");
			var DustIcon1:Class = ResourceHelper.getInstance().getClassByName("DustIcon1");
			iconImg = new ImgSwitchIcon(DustIcon0, DustIcon1);
			addChild(iconImg);
			this.anchor = ANCHOR_RIGHT_BOTTOM;
			this.x = -100;
			this.y = -150;
			hideFlag = true;
			iconImg.x = width + 100;
			this.addEventListener(MouseEvent.CLICK, onMouseClick);
		}
		
		public function hide():void
		{
			hideFlag = true;
			TweenLite.to(iconImg, 2, {x: iconImg.width + 100});
		}
		
		public function show():void
		{
			hideFlag = false;
			TweenLite.to(iconImg, 2, {x: 0});
		}
		
		private function onMouseClick(event:Event):void
		{
			var MovieCloud:Class = ResourceHelper.getInstance().getClassByName("MovieCloud3");
			var movieCloud:BasicMc = new BasicMc(MovieCloud, 20, false, true);
			addChild(movieCloud);
			BSound.getInstance().playEffect("SoundTowerDiscarded");
			HomeScene.getInstance().getCurrentTown().finishBuild();
		}
		
	}
}